import { VuexModule, Module, Action, getModule, Mutation } from 'vuex-module-decorators'
import { NFT_CONTRACT, nftAbi } from '@/contract'

import store from '@/store'

export interface NFTState {
}

@Module({ dynamic: true, store, name: 'NFT', namespaced: true })
class NFT extends VuexModule implements NFTState {

    @Action({ rawError: true })
    public dividends(address = store.getters.userAddr): Promise<any> {
        const contract = new store.getters.web3.eth.Contract(nftAbi, NFT_CONTRACT);
        return contract.methods.dividends(address).call()
    }
}

export const NFTModule = getModule(NFT)